////////////////////////////////carEdit/////////////////////////////////
$(document).on("pageInit", "#page_carEdit", function(e, pageId, $page) {
                  my.givetitle('车辆编辑');
                  setTimeout(function(){
                  	$.showPreloader()
                  },1)

      	    	   var key=my.get_key(my.getCookie('token'))
                   //获取照片
                   var info_carEdit={
      						     //'u_userid':sessionStorage.id,
      						     'cars_id':sessionStorage.car_id,
      					                }
    					info_carEdit=JSON.stringify(info_carEdit)
                        info_carEdit=my.cryptoASEencrypt(info_carEdit,key)
                        $.ajax({
      					url:api.getcarsinfo,
      					type: 'post',
      					async:true,
      					data:{
      						'api_value':info_carEdit
      					},
      					error:function(){
      							$.toast("请求失败，请刷新重试");
      						},
//    					complete:function(){
//    						setTimeout(function(){
//    							$.hidePreloader()
//    						},10)
//    					},
      					success:function(data){
      						$.hidePreloader()
      						if(data.match("err_code")!=null){
      							switch(JSON.parse(data).err_code)
      								{
      									case 40003:
      									    my.tokenExpire()
      									   break;
      									default:
      									   $.toast(JSON.parse(data).err_msg);
      								}
      						}else{
      								  data=JSON.parse(data)
                                      data=JSON.parse(my.cryptoASEdencrypt(data.data,key))
                                      console.log(data)
      								if(data['carimg'].length==0){
      									$('.swiper-slide-hold').css('display','block')
      								    $('.swiper-slide-hold img').attr('src',config.url_car+'/models/20160608102036852147.jpg')
      								}else{
      									$('.swiper-wrapper').empty()
      							      for(i=0;i<data['carimg'].length;i++){
      							    	var src='<div class="swiper-slide"><img id="'+data['carimg'][i].image_id+'" src="'+config.url+data['carimg'][i].image_bigurl+'">'
      							    	$(src).appendTo('.swiper-wrapper')
      							       }
      							    }
      							    var mySwiper = new Swiper('.swiper-container',{
                                                       pagination : '.swiper-pagination',
                                                       paginationElement : 'li',
                                                })
      							    $('.cars_name').text(data['cars_name'])
      							    $('.car_platee').text(data['car_plate'])
      							    if(data['auditresult_state']==1){
      							    	$('.carEdit-list').css('display','block')
      							    	$('.auditresult_state').html('<img src="/h5car/img/icon/ok.png" style="width:15px;margin: 0 5px -2px 0;display:inline-block;">认证通过</div>')
      							    	$('.vehicle_name').text(data['vehicle_name'])
      							        $('.identification').text(data['identification'])
      							        $('.vehicle_registetime').text(data['vehicle_registetime'].substr(0,11))
      							        $('.vehicle_endtime').text(data['vehicle_endtime'].substr(0,11))
      							        $('.vehicle_number').text(data['vehicle_number'])
      							    }else if(data['auditresult_state']==2){
      							    	$('.auditresult_state').html('<img src="/h5car/img/icon/no.png" style="width:15px;margin: 0 5px -2px 0;display:inline-block;">认证失败</div>')
      							    	$('[name=car_carid]').val(data['usercar_id'])
      							    	$('.sel-car').text(data['brand_chinese_name'])
      							    	$('[name=brand_id]').val(data['brand_id'])
      							        $('[name=brand_name]').val(data['brand_chinese_name'])
      							        $('[name=cars_id]').val(data['cars_id'])
      							        $('[name=cars_name]').val(data['cars_name'])
      							        $('[name=models_id]').val(data['models_id'])
      							        $('[name=models_name]').val(data['models_name'])
      							        $('[name=c_number]').val(data['car_plate'])
      							        $('.carEdit-way').attr('href','#page_checkCar_carEdit').text('点击认证')
      							    }else if(data['auditresult_state']==0){
      							    	$('.auditresult_state').html('<div>认证中</div>')
      							    }else if(data['auditresult_state']==3){
      							    	$('.auditresult_state').html('<img src="/h5car/img/icon/no.png" style="width:15px;margin: 0 5px -2px 0;display:inline-block;">未认证</div>')
      							        $('[name=car_carid]').val(data['usercar_id'])
      							    	$('.sel-car').text(data['brand_chinese_name']+'-'+data['cars_name'])
      							    	$('[name=brand_id]').val(data['brand_id'])
      							        $('[name=brand_name]').val(data['brand_chinese_name'])
      							        $('[name=cars_id]').val(data['cars_id'])
      							        $('[name=cars_name]').val(data['cars_name'])
      							        $('[name=models_id]').val(data['models_id'])
      							        $('[name=models_name]').val(data['models_name'])
      							        $('[name=c_number]').val(data['car_plate'])
      							        $('.carEdit-way').attr('href','#page_checkCar_carEdit').text('点击认证')
      							    }
      							}
      					}
      				});
      				//删除图片
      				$('.del-img').off('click').on('click',function(){
      					                      $.confirm('确认要删除么', function () {
      					                      	$.showPreloader()
      					                      	var info_carEdit_delImg={
      						                          // 'u_userid':sessionStorage.id,
      						                           'image_id':$('.swiper-slide-active img').attr('id'),
      						                           'cars_id':sessionStorage.car_id,
      					                              }
      					                      	    console.log(info_carEdit_delImg)
    					                            info_carEdit_delImg=JSON.stringify(info_carEdit_delImg)
                                                    info_carEdit_delImg=my.cryptoASEencrypt(info_carEdit_delImg,key)
      					                            $.ajax({
      						                        type:"post",
      						                        url:api.userdelcarimg,
      						                        data:{
      							                       'api_value':info_carEdit_delImg,
      						                           },
      						                        async:true,
      						                        error:function(){
      							                                    $.hidePreloader()
      							                                    $.alert("删除失败，请重试");
      							                                    //$.router.reloadPage()
      						                                      },
      						                        success:function(data){
      						                        	$.hidePreloader()
      							                        if(data.match("err_code")!=null){
      								                     switch(JSON.parse(data).err_code)
      								                     {
      									                   case 40003:
      									                    my.tokenExpire()
      									                   break;
      									                  default:
      									                    $.alert(JSON.parse(data).err_msg);
      									                    //$.router.reloadPage()
      								                     }

      							                        }else{
        								                 	$.alert('删除成功',function(){
        								                 		my.reload()
        								                 	})
                                                          }
      					                         	},
      					                           });
                                               });
      				                        })
      				//删除汽车
      				$('.delete-car').off('click').on('click',function(){
      					                   var cars_id=sessionStorage.car_id
      					                      $.confirm('确认要删除么', function () {
      					                      	$.showPreloader()
      					                      	var info_carEdit_delCar={
      						                          // 'u_userid':sessionStorage.id,
      						                           'u_userid':my.getCookie('id'),
      						                           'cars_id':cars_id,
      					                              }
    					                            info_carEdit_delCar=JSON.stringify(info_carEdit_delCar)
                                                    info_carEdit_delCar=my.cryptoASEencrypt(info_carEdit_delCar,key)
      					                            $.ajax({
      						                        type:"post",
      						                        url:api.usercardelete,
      						                        data:{
      							                       'api_value':info_carEdit_delCar,
      						                           },
      						                        async:true,
      						                        error:function(){
      							                                    $.hidePreloader()
      							                                    $.toast("删除失败，请重试");
      							                                    //$.router.reloadPage()
      						                                      },
      						                        success:function(data){
      						                        	$.hidePreloader()
      							                        if(data.match("err_code")!=null){
      								                     switch(JSON.parse(data).err_code)
      								                     {
      									                   case 40003:
      									                    my.tokenExpire()
      									                   break;
      									                  default:
      									                    $.toast(JSON.parse(data).err_msg);
      								                     }

      							                        }else{
        								                 	$.alert('删除成功',function(){
        								                 		//$.router.load("carManger.html",true)
                                                                $.router.load(carMangerUrl,true)
        								                 		//$('[name='+cars_id+']').css('display','none')
        								                 	})
                                                          }
      					                         	},
      					                           });
                                               });
      				                        })

                 //添加照片
                 $('.carEdit-img-tj').off('click').on('click',function(){
                 var list={"id":".carEdit-img-tj","text":"no"}
                     list=JSON.stringify(list)
                     //alert(list);
                     /*  showinmage(list);
                 	 /*var list={"id":".carEdit-img-tj","text":"no"}
      			         list=JSON.stringify(list)
      			         ad.native_get_photo(list)*/
                     var proc=function(){
                         showinmage(list);
                     };
                     callwechatselectimg(proc);

                })
});